<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('增加/项目操作方式')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <form class="form-horizontal m" id="form-horizontal m">
        <input name="trainPackageProjectId" id="trainPackageProjectId" th:value="${trainPackageProjectId}" type="hidden"/>
        <div id="menuTrees" class="ztree ztree-border"></div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    // 权限

    // 字典
    var prefix = ctx + "business/trainPackageProject";
    $(function () {
        var url = prefix + "/getProjectTree?trainPackageProjectId=" + $("#trainPackageProjectId").val();
        var options = {
            id: "menuTrees",
            url: url,
            check: {enable: true, chkboxType: {"Y": "", "N": ""}},
            expandLevel: 0
        };
        $.tree.init(options);

    });

    function edit() {
        var trainPackageProjectId = $("#trainPackageProjectId").val();
        var menuIds = $.tree.getCheckedNodes();
        var reqData = {
            "id": trainPackageProjectId,
            "integrationIds": menuIds
        };
        $.ajax({
            type: "POST",
            url: prefix + "/saveProject",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify(reqData),
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        edit();
    }


</script>
</body>

</html>